package com.tpp.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @Package: com.tpp.config
 * @ClassName: SwaggerConfig
 * @Author: myh
 * @CreateTime: 2021/9/11 12:00
 * @Description:
 */

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
                .pathMapping("/")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.tpp.controller"))
                .build(
                );
    }

    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("spring cloud api 说明文档")
                .description("接口说明文档")
                .termsOfServiceUrl("")  //这个是服务条款网址
                .contact(new Contact("wdq","",""))  //注意，contact需要与提供者的配置一致
                .version("1.0")
                .build();
    }
}
